//大鱼
var momObj=function(){
	this.x;
	this.y;
//	this.bigEye=new Image();//大鱼的眼睛
//	this.bigBody=new Image();//大鱼的身体
//	this.bigTail=new Image();//大鱼的尾巴
	
	this.angle;//大鱼的角度
	
	
	this.momTailTimer=0;//大鱼尾巴计时器
	this.momTailCount=0;//大鱼尾巴当前数
	
	
	this.momEyeTimer=0;
	this.momEyeCount=0;
	this.momEyeInterval=1000;
	
	this.momBodyCount=0;//身体颜色的计数器
	
}
momObj.prototype.init=function(){
	this.x=canWidth*0.5;
	this.y=canHeight*0.5;
//	this.bigEye.src="src/bigEye0.png";
//	this.bigBody.src="src/bigSwim0.png";
//	this.bigTail.src="src/bigTail0.png";
	this.angle=0;
	
	
}
momObj.prototype.draw=function(){
	
	//lerp,x,y让大鱼的坐标一直趋向于鼠标的坐标
	this.x =lerpDistance(mx,this.x,0.98);
	this.y =lerpDistance(my,this.y,0.98);
	
	//坐标差delta  angle
	//Math.atan2(y,x);
	var deltaY=my-this.y;
	var deltaX=mx-this.x;
	var beta=Math.atan2(deltaY,deltaX)+Math.PI;
	
	//lerp  angle让大鱼的角度一直趋向于鼠标的坐标
	this.angle=lerpAngle(beta,this.angle,0.9);
	
	//tail
	this.momTailTimer+=deltaTime;
	if (this.momTailTimer>50) {
		
		this.momTailCount=(this.momTailCount+1)%8;
		this.momTailTimer%=50;
	}
	
	
	//eye
	this.momEyeTimer+=deltaTime;
	if (this.momEyeTimer>this.momEyeInterval) {
		
		this.momEyeCount=(this.momEyeCount+1)%2;
		this.momEyeTimer%=this.momEyeInterval;
		if (this.momEyeCount==0) {
			this.momEyeInterval=Math.random()*1500+2000;
		}else{
			this.momEyeInterval=200;
		}
	}
	
	ctx1.save();
	ctx1.translate(this.x,this.y);
	ctx1.rotate(this.angle);
	
	var momTailCount=this.momTailCount;
	ctx1.drawImage(momTail[momTailCount],-momTail[momTailCount].width*0.5+30,-momTail[momTailCount].height*0.5);
	
	var momBodyCount=this.momBodyCount;
	if (data.double==1) {
	ctx1.drawImage(momBodyOrange[momBodyCount],-momBodyOrange[momBodyCount].width*0.5,-momBodyOrange[momBodyCount].height*0.5);
		
	}else{
	ctx1.drawImage(momBodyBlue[momBodyCount],-momBodyBlue[momBodyCount].width*0.5,-momBodyBlue[momBodyCount].height*0.5);
		
	}

	
	var momEyeCount=this.momEyeCount;
	ctx1.drawImage(momEye[momEyeCount],-momEye[momEyeCount].width*0.5,-momEye[momEyeCount].height*0.5);


	
	ctx1.restore();//在save（）与restore（）之间的代码只作用于大鱼
}
